<?php
class AppAction 
{
	public static $conn;
	function __construct(){
		require_once APP_PATH . 'common/UserSession.php';
		require_once APP_PATH . 'common/WebVistor.php';		
		require_once SOURCE_EXT_PATH. 'common/ModelLib.class.php';
		require_once APP_LIB_PATH . 'formLib.php';
		$this->connectDatabase();
		
	}
	
	//连接数据库操作
	public function connectDatabase(){
		//如果前后台不一致，可以修改这边的引用信息
		require_once SOURCE_EXT_PATH . 'config/dbConfig.php';
		self::$conn=mysql_connect($dataBase_host,$dataBase_user,$dataBase_password);
		if (! self::$conn)
		{
			die ( 'Could not connect: ' . mysql_error () );
		}
		mysql_query('SET NAMES UTF8');
		mysql_select_db($dataBase_name, self::$conn) or die ('Can\'t use foo : ' . mysql_error());
	}
	
	//类执行完之后清除数据库连接
	function __destruct(){
		if(self::$conn){
			mysql_close(self::$conn);
		}
	}
}

